package com.dxq.test.adapter;

import android.widget.CompoundButton;
import android.widget.TextView;

import com.blankj.utilcode.util.TimeUtils;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.dxq.test.App;
import com.dxq.test.R;
import com.dxq.test.bean.RemindEntity;
import com.dxq.test.db.Breed;
import com.dxq.test.db.Vaccine;

import org.jetbrains.annotations.NotNull;

import java.util.List;

/**
 * Author: zsh
 * Date: 2023/12/6
 * Describe: oms订单列表adapter
 */
public class RemindAdapter extends BaseMultiItemQuickAdapter<RemindEntity, BaseViewHolder> {

    public RemindAdapter(List<RemindEntity> data) {
        super(data);
        addItemType(RemindEntity.TYPE_B, R.layout.item_remind);
        addItemType(RemindEntity.TYPE_V, R.layout.item_remind);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, RemindEntity item) {
        switch (holder.getItemViewType()) {
            case RemindEntity.TYPE_B://预产或配种
                Breed breed = item.getBreed();
                holder.setText(R.id.tvCode, breed.getCode());
                holder.setText(R.id.tvType, item.getTypeRemind());
                holder.setText(R.id.tvTime, item.getTypeRemind().equals("预产") ? breed.getBirth_time() : breed.getNext_time());
                holder.setText(R.id.tvInfo, item.getInfo());
                if (item.getTimeSpan() - TimeUtils.getNowMills() > 0l)
                    holder.setText(R.id.tvRemindTime, TimeUtils.getFitTimeSpan(item.getTimeSpan(),
                            TimeUtils.getNowMills(), 3));
                else
                    holder.setText(R.id.tvRemindTime, "已过期");
                break;

            case RemindEntity.TYPE_V://防治
                Vaccine vaccine = item.getVaccine();
                holder.setText(R.id.tvCode, vaccine.getCode());
                holder.setText(R.id.tvType, item.getTypeRemind());
                holder.setText(R.id.tvTime, vaccine.getNext_time());
                holder.setText(R.id.tvInfo, item.getInfo());
                if (item.getTimeSpan() - TimeUtils.getNowMills() > 0l)
                    holder.setText(R.id.tvRemindTime, TimeUtils.getFitTimeSpan(item.getTimeSpan(),
                            TimeUtils.getNowMills(), 3));
                else
                    holder.setText(R.id.tvRemindTime, "已过期");
                break;
        }

    }
}
